<span page-title ng-model="contentView">{{ 'Versions for Content View:' | translate }} {{ contentView.name }}</span>

<div data-extend-template="layouts/partials/table.html">
  <span data-block="no-rows-message" translate>
    This Content View does not have any versions, create your first Content View Version by using the "Publish New Version" button on the right.
  </span>

  <span data-block="no-search-results-message" translate>
    Your search returned zero Content View.
  </span>

  <div data-block="table">
    <table class="table table-striped table-bordered" bst-table="table">
      <thead>
        <tr bst-table-head>
          <th bst-table-column><span translate>Version</span></th>
          <th bst-table-column><span translate>Status</span></th>
          <th bst-table-column><span translate>Environments</span></th>
          <th bst-table-column><span translate>Content</span></th>
          <th bst-table-column><span translate>Description</span></th>
          <th class="col-sm-2" bst-table-column><span translate>Actions</span></th>
        </tr>
      </thead>

      <tbody>
        <tr bst-table-row ng-repeat="version in table.rows">
          <td bst-table-cell translate>
            <a ui-sref="content-view.version.details({versionId: version.id})" >Version {{ version.version }}</a>
          </td>
          <td bst-table-cell >
            <a ng-href="/foreman_tasks/tasks/{{ version.last_event.task.id }}"
               ng-hide="hideProgress(version)">

              <div ng-class="{ active: taskInProgress(version) }"
                class="progress progress-striped">
                <span uib-progressbar animate="false" value="version.task.progressbar.value" type="{{version.task.progressbar.type}}"></span>
              </div>

              {{ status(version) }}
            </a>

            <span ng-show="hideProgress(version)">
              {{ historyText(version) }}
              (<short-date-time date="version.last_event.created_at" />)
            </span>
          </td>
          <td bst-table-cell>
            <ul class="list-unstyled">
              <li ng-repeat="environment in version.environments" ng-if="environment.permissions.readable">
                {{ environment.name }}
              </li>
            </ul>
          </td>
          <td bst-table-cell>
            <div translate ng-if="version.package_count && version.package_count > 0">
              {{ version.package_count }} Packages
            </div>
            <div translate ng-if="version.srpm_count && version.srpm_count > 0">
              {{ version.srpm_count }} Source RPMs
            </div>
            <div  ng-if="version.errata_counts.total && version.errata_counts.total > 0">
              <span translate>{{ version.errata_counts.total }} Errata</span>
              (<span errata-counts="version.errata_counts"></span>)
            </div>
            <div translate ng-if="version.module_stream_count && version.module_stream_count > 0">
              {{ version.module_stream_count }} Module Streams
            </div>
            <div translate ng-if="version.docker_manifest_count && version.docker_manifest_count > 0">
              {{ version.docker_manifest_count }} Container Image Manifests
            </div>
            <div translate ng-if="version.docker_manifest_list_count && version.docker_manifest_list_count > 0">
              {{ version.docker_manifest_list_count }} Container Image Manifest Lists
            </div>
            <div translate ng-if="version.docker_tag_count && version.docker_tag_count > 0">
              {{ version.docker_tag_count }} Container Image Tags
            </div>
            <div translate ng-if="version.ostree_branch_count && version.ostree_branch_count > 0">
              {{ version.ostree_branch_count }} OSTree Branches
            </div>
            <div translate ng-if="version.file_count && version.file_count > 0">
              {{ version.file_count }} Files
            </div>
            <div translate ng-if="version.deb_count && version.deb_count > 0">
              {{ version.deb_count }} deb Packages
            </div>
          </td>
          <td bst-table-cell class="preserve-newlines">{{ version.description }}</td>
          <td class="col-sm-2">
            <div class="btn-group">
              <button type="button" class="btn btn-default"
                ng-click="$state.go('content-view.promotion', {contentViewId: contentView.id, versionId: version.id})"
                ng-hide="denied('promote_or_remove_content_views', contentView)"
                ng-disabled="taskInProgress(version) || taskFailed(version) || pendingVersionTask">
                <span translate>
                  Promote
                </span>
              </button>              <button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <span class="caret"></span>
                <span class="sr-only">Toggle Dropdown</span>
              </button>
              <ul class="dropdown-menu">
                <li>
                  <a href="#"
                     ng-click="$state.go('content-view.promotion', {contentViewId: contentView.id, versionId: version.id})"
                     ng-hide="denied('promote_or_remove_content_views', contentView)"
                     ng-disabled="taskInProgress(version) || taskFailed(version) || pendingVersionTask"
                     translate>
                     Promote
                  </a>
                </li>
                <li>
                  <a href="#"
                     ng-click="regenerateRepositories(version)"
                     ng-hide="denied('promote_or_remove_content_views', contentView)"
                     ng-disabled="taskInProgress(version) || taskFailed(version) || pendingVersionTask"
                     translate>
                     Regenerate Repository Metadata
                  </a>
                </li>
                <li>
                  <a href="#"
                     ng-click="$state.go('content-view.version-deletion.environments', {contentViewId: contentView.id, versionId: version.id})"
                     ng-hide="denied('promote_or_remove_content_views', contentView)"
                     ng-disabled="taskInProgress(version) || taskFailed(version) || pendingVersionTask"
                     translate>
                      Remove
                  </a>
                </li>
              </ul>
            </div>
          </td>
        </tr>
      </tbody>
    </table>

  </div>

</div>
